www.stonehorse.comGeometryManager
Version 1.01

Home ] Introduction ] [ Overview ] Platform Notes ] Reference ] History ]

Overview

GeometryManager uses a simple parent-child method of specifying the layout of the controls in the resizable window. There are three ways to control how a group and its children are sized and positioned.

  • Arrangement of children. Child groups can be arranged in one of three ways: horizontally or vertically in the order that they are added to the manager, or overlapped. The overlapped arrangement is useful when adding tab pages.
  • Growth or Alignment. A group can be allowed to grow or to align a specific way both horizontally and vertically. Generic groups inherit the growth properties of their child groups. If the children can grow, then the generic group grows as well. If the children can’t grow, then the generic group will be aligned as its flags specify. The minimum size of window groups are defined by their size in the resource file.
  • Weight. Each group has a weight that determines how much of the extra space gets assigned to that group relative to all sibling groups. The weight is applied equally to both the vertical and horizontal extra space and is ignored for groups that cannot grow. If you have three child groups, each with a weight of 1, then each group gets 1 / 3 of the total extra space. If you have three child groups, two with a weight of 1 and the last with a weight of 2, then the first two get 1 / 4 of the total extra space and the last gets 1 / 2 of the total extra space.

Group Extra Space = Total Extra Space * Group Weight / Total Sibling Group Weight

The layout starts out with a top-level group as the first control added to the geometry manager. A top-level group is a dialog, an MDI child frame, or an SDI frame window. All direct child groups are arranged horizontally, vertically or overlapped in the order that they are added to the manager. This applies to children of any group. All groups, except top-level groups, have a weight. Some groups are windows, while other groups are simply placeholders for more child groups. In this way any layout desired can be created.

The first function you should call is GmRegister. If you have purchased GeometryManager, then you will pass your 16 character registration code into this function to unlock the DLL. If you have not purchased GeometryManager, then this function does nothing and simply returns false.

The geometry manager layout should be initialized after all child windows have been created and before the window is shown. For dialogs, this is done in a WM_INITDIALOG message handler. For frame windows, this is done in a WM_INITIALUPDATE message handler.

Let’s look at a simple example dialog with one multi-line edit field and an associated static text label, along with OK and Cancel buttons. The code and diagram will speak for themselves.

This is the example dialog in at its minimum size:

Example Dialog at Minimum Size

This is the example dialog sized a bit larger:

Example Dialog Sized Larger

Layout Diagram

This is a diagram of the groups that define the geometry of the example dialog. Each of the rectangles represents one group.

Example Dialog Layout Diagram

Source Code

This code would appear in your handler for WM_INITDIALOG.

// initialize the geometry manager
//
// the default behavior is fine
//
HGEOM hGeom = GmStartDefinition(0);
if (hGeom)
{
    // add the top-level dialog group
    //
    // arrange its direct children vertically
    //
    HGMGROUP hTopDialog = GmAddTopDialog(hGeom, m_hWnd, GM_VERTICAL);
    if (hTopDialog)
    {
        // add the generic group for the static text and edit field
        //
        // arrange its direct children vertically
        // give it a weight of 1
        //
        HGMGROUP hGroup1 = GmAddGroup(hGeom, hTopDialog, GM_VERTICAL, 1);
        if (hGroup1)
        {
            // add the static text group
            //
            // left-align and vertically center it
            // give it a weight of 0
            //
            GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_SI_LABEL), GM_LEFT | GM_VCENTER, 0);

            // add the multiline edit field group
            //
            // allow it to grow (in both directions)
            // give it a weight of 1
            //
            GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_SI), GM_GROW, 1);
        }

        // add the generic group for the buttons
        //
        // right-align it
        // arrange its direct children horizontally
        // give it a weight of 0
        //
        hGroup1 = GmAddGroup(hGeom, hTopDialog, GM_RIGHT | GM_HORIZONTAL, 0);
        if (hGroup1)
        {
            // add the two buttons
            //
            // don't allow any growth
            // give them a weight of 0
            //
            GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDOK), 0, 0);
            GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDCANCEL), 0, 0);
        }
    }

    // end the definition and start the manager
    //
    GmEndDefinition(hGeom);
}


Please send any technical questions to techsupport@stonehorse.com
Copyright ⌐ 1998 Stonehorse Software
Last updated July 08, 1998.